<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="../js/mui.min.js"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<script type="text/javascript" src="../js/localData.js" ></script>
		<style>
			.mui-bar-tab .mui-tab-item.mui-active {
				color: #ff6161;
			}
			
			.mui-bar {
				box-shadow: none;
				-webkit-box-shadow: none;
			}
		</style>
	</head>

	<body>
		<nav class="mui-bar mui-bar-tab">
			<a id="defaultTab" class="mui-tab-item mui-active" name="home.html" href="home.html">
				<span class="mui-icon mui-icon-home"></span>
				<span class="mui-tab-label">首页</span>
			</a>
			<a class="mui-tab-item" name="find.html" href="find.html">
				<span class="mui-icon mui-icon-eye"></span>
				<span class="mui-tab-label">发现</span>
			</a>
			<a class="mui-tab-item" name="personal.html" href="personal.html">
				<span class="mui-icon mui-icon-contact"></span>
				<span class="mui-tab-label">我的</span>
			</a>
			<a class="mui-tab-item" name="system.html" href="system.html">
				<span class="mui-icon mui-icon-gear"></span>
				<span class="mui-tab-label">更多</span>
			</a>
		</nav>
		<script type="text/javascript" src="../js/request.js"></script>
		<script type="text/javascript" src="../script/share/checkVersion.js"></script>
		<script type="text/javascript" charset="UTF-8">
			mui.init();
			var subpage_style = {
				top: '0px',
				bottom: '51px'
			};
			var self;
			//创建子页面，首个选项卡页面显示，其它均隐藏；
			mui.plusReady(function() {
				plus.navigator.closeSplashscreen();
				self = plus.webview.currentWebview();
				var parent = self.opener()
				var defaultTab = document.getElementById("defaultTab");
				localStorage.marketWebId = writeData("5be26f8f-ef58-4627-b58f-dca666ee7612");
				if (localStorage.marketWebId) {
					defaultTab.setAttribute("name", "homeMarket.html");
				}
				//模拟首页点击
				mui.trigger(defaultTab, 'tap');
				if (parent) {
					parent.close();
					if (parent.opener()) {
						parent.opener().close();
					}
				}
			});
			//当前激活选项
			var activeTab = 1;
			//选项卡点击事件
			mui('.mui-bar-tab').on('tap', 'a', function(e) {
					var viewid = vurl = this.name; //获得当前点击窗口id
					var targetView = plus.webview.getWebviewById(viewid);
					if (targetView == activeTab) {
						return;
					}
					if (targetView) {
						targetView.show("fade-in");
						activeTab = targetView;
					} else {
						creatView(vurl, viewid);
					}
				})
				//创建不同子webview
			function creatView(vurl, viewId) {
				//var w=plus.nativeUI.showWaiting();
				var sub = plus.webview.create(vurl, viewId, subpage_style);
				self.append(sub);
				activeTab = sub;
			}
			checkversion(true);
			//处理逻辑：1秒内，连续两次按返回键，则退出应用；
			var first = null;
			mui.back = function() {
				//首次按键，提示‘再按一次退出应用’
				if (!first) {
					first = new Date().getTime();
					mui.toast('再按一次退出应用');
					setTimeout(function() {
						first = null;
					}, 1000);
				} else {
					if (new Date().getTime() - first < 1000) {
						plus.runtime.quit();
					}
				}
			}
		</script>
	</body>

</html>